﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:userInterfaceLibrary="clr-namespace:MyCompany.UserInterfaceLibrary">
    <Style x:Key="EditableTabHeaderControl" TargetType="{x:Type userInterfaceLibrary:EditableTabHeaderControl}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type userInterfaceLibrary:EditableTabHeaderControl}">
                    <Grid>
                        <TextBox x:Name="PART_TabHeader"
                                 Text="{Binding RelativeSource={RelativeSource TemplatedParent},
                                                Path=Content,
                                                Mode=TwoWay}"
                                 Visibility="Collapsed" />
                        <TextBlock x:Name="PART_TextBlock" Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content, Mode=TwoWay}" />
                    </Grid>
                    <ControlTemplate.Triggers>

                        <Trigger Property="IsInEditMode" Value="True">
                            <Trigger.Setters>
                                <Setter TargetName="PART_TabHeader" Property="Visibility" Value="Visible" />
                                <Setter TargetName="PART_TextBlock" Property="Visibility" Value="Collapsed" />
                            </Trigger.Setters>
                        </Trigger>

                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>